<?php

namespace myshop\login\controller;

use longhu\base\AdminBaseController;
use longhu\MyResponse;
use myshop\common\middleware\AdminApiLogMiddleware;
use think\annotation\route\Middleware;
use think\annotation\route\Route;
use think\response\Json;

class AdminLogin extends AdminBaseController
{

    public function register()
    {
        $params = request()->param();

    }
    /**
     * 管理员登录
     * @return Json
     *
     */
    #[Route("GET|POST","sys/auth/login")]
    #[Middleware(AdminApiLogMiddleware::class)]
    public function login()
    {
        $userInfo = [
            'id'=>1,
            'nickname'=>"小不点",
            'department'=>"经理",
            'department_id'=>1,
            'phone'=>'1333333333',
            'true_name'=>"张三",
            'areas'=>[
                ['name'=>'四川省','value'=>'1','level'=>1],
                ['name'=>'成都市','value'=>'2','level'=>2],
                ['name'=>'成都市','value'=>'3','level'=>3],
            ],
            'address'=>'三河场街道2号',
            'avatar'=>''
        ];
        $token = app('JWT')->createToken((int)$userInfo['id'],'sys',[]);
        return MyResponse::success([
            "userInfo"=>$userInfo,
            'tokenInfo'=>$token
        ]);
    }

    /**
     * @return \think\Response
     */
    #[Route("GET","sys/captcha/:type")]
    public function getVerufyCode($type = 'admin_login')
    {
        $image =  captcha($type);
        dump($image->getData());exit;
    }


}